package com.ruoyi.system.mapper;

import java.util.List;
import com.ruoyi.system.domain.FyPeople;
import com.ruoyi.system.domain.vo.web.WebPeopleVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 传承人信息Mapper接口
 *
 * @author ruoyi
 * @date 2025-06-05
 */
public interface FyPeopleMapper
{
    /**
     * 查询传承人信息
     *
     * @param peopleId 传承人信息主键
     * @return 传承人信息
     */
    public FyPeople selectFyPeopleByPeopleId(Long peopleId);

    /**
     * 查询传承人信息列表
     *
     * @param fyPeople 传承人信息
     * @return 传承人信息集合
     */
    public List<FyPeople> selectFyPeopleList(FyPeople fyPeople);

    @Select(
            "<script> select people_id as peopleId,\n" +
            "people_name as peopleName,\n" +
            "people_mz as peopleMz,\n" +
            "people_birth as peopleBirth,\n" +
            "`people_sex` as `peopleSex`,\n" +
            "people_level as peopleLevel,\n" +
            "project_name as projectName,\n" +
            "project_type as projectType,\n" +
            "project_batch as projectBatch,\n" +
            "time as time,\n" +
            "unit as unit from fy_people\n" +
            " <where>\n" +
            "            <if test=\"peopleName != null  and peopleName != ''\"> and people_name like concat('%', #{peopleName}, '%')</if>\n" +
            "            <if test=\"projectName != null  and projectName != ''\"> and project_name like concat('%', #{projectName}, '%')</if>\n" +
            "            <if test=\"projectType != null  and projectType != ''\"> and project_type = #{projectType}</if>\n" +
            "            <if test=\"peopleLevel != null  and peopleLevel != ''\"> and people_level = #{peopleLevel}</if>\n" +
            "          and  is_delete = 0\n" +
            "        </where> " +
                    "ORDER BY \n" +
                    "    CASE \n" +
                    "        WHEN project_type = '民间文学' THEN 1\n" +
                    "        WHEN project_type = '传统音乐' THEN 2\n" +
                    "        WHEN project_type = '传统舞蹈' THEN 3\n" +
                    "        WHEN project_type = '传统戏剧' THEN 4\n" +
                    "        WHEN project_type = '曲艺' THEN 5\n" +
                    "        WHEN project_type = '传统体育、游艺与杂技' THEN 6\n" +
                    "        WHEN project_type = '传统美术' THEN 7\n" +
                    "        WHEN project_type = '传统技艺' THEN 8\n" +
                    "        WHEN project_type = '传统医药' THEN 9\n" +
                    "        WHEN project_type = '民俗' THEN 10\n" +
                    "        ELSE 11\n" +
                    "    END,\n" +
                    "    convert(people_name using gbk) ASC </script>")
    public List<WebPeopleVo> selectWebPeople(@Param("peopleName")String peopleName ,
                                             @Param("projectName")String projectName,
                                             @Param("projectType")String projectType,
                                             @Param("peopleLevel")String peopleLevel);

    /**
     * 新增传承人信息
     *
     * @param fyPeople 传承人信息
     * @return 结果
     */
    public int insertFyPeople(FyPeople fyPeople);

    /**
     * 修改传承人信息
     *
     * @param fyPeople 传承人信息
     * @return 结果
     */
    public int updateFyPeople(FyPeople fyPeople);

    /**
     * 删除传承人信息
     *
     * @param peopleId 传承人信息主键
     * @return 结果
     */
    public int deleteFyPeopleByPeopleId(Long peopleId);

    /**
     * 批量删除传承人信息
     *
     * @param peopleIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFyPeopleByPeopleIds(Long[] peopleIds);
}
